﻿<script src="javascript/datetimepicker_css.js"></script>

<?php
// Returns TRUE if request is post otherwise FALSE
$sensor = $_GET["sensor"];
function isPost()
{
    return (strtolower($_SERVER['REQUEST_METHOD']) === "post") ? TRUE : FALSE;
}

// Now you can do:
if(isPost())
{
    $date = $_POST["datetimepiker"];
	if($date=="")
		echo "
		<form action=\"choiseday.php?sensor=$sensor\" method=\"POST\">
		<input type=\"text\" name=\"datetimepiker\" id=\"datetimepiker\" maxlength=\"25\" size=\"25\"/>
		<img src=\"image/cal.gif\" onclick=\"javascript:NewCssCal('datetimepiker','DDMMYYYY')\" style=\"cursor:pointer\" />
		<input type=\"submit\" name=\"submit\" value=\"Xem biểu đồ\">
		<p style=\"color:#FF0000\">Bạn phải chọn ngày!</p>
		</form>";
	else
	{
		print "<script type='text/javascript'>";
		print "window.open('../grapham.php?date=$date&sensor=$sensor','popUpWindow','status=1,scrollbars=1,resizable=0,menu=no,width=320,height=220');";
		print "</script>"; 		
	}
}
else
{
    echo "<form action=\"choiseday.php?sensor=$sensor\" method=\"POST\">
	<input type=\"text\" name=\"datetimepiker\" id=\"datetimepiker\" maxlength=\"25\" size=\"25\"/>
	<img src=\"image/cal.gif\" onclick=\"javascript:NewCssCal('datetimepiker','DDMMYYYY')\" style=\"cursor:pointer\" />
	<input type=\"submit\" name=\"submit\" value=\"Xem biểu đồ\">";
}
?>